package com.storm.lib.base;


import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

public abstract class BaseServerHandler extends IoHandlerAdapter{
	public static long lastTime=0;
	public static long deltaTimes=1;
	public static long totalTimes=0;

    public abstract void exceptionCaught( IoSession session, Throwable cause ) throws Exception;


    public abstract void messageReceived( IoSession session, Object message ) throws Exception;


    public abstract void sessionIdle( IoSession session, IdleStatus status ) throws Exception;


	public abstract void messageSent(IoSession session, Object message) throws Exception;


	public abstract void sessionClosed(IoSession session) throws Exception;


	public abstract void sessionCreated(IoSession session) throws Exception;
	public abstract void sessionOpened(IoSession session) throws Exception;
	
	public void sendSecurity(IoSession session) {
		String xml="<cross-domain-policy>\n"
			+ "<site-control permitted-cross-domain-policies=\"all\"/>\n"
			+ "<allow-access-from domain=\"*\" to-ports=\"*\" />\n"
			+ "</cross-domain-policy>\n";
		session.write(xml + "\0");
	}
    
}
